package dyyx.dto;

import java.io.IOException;
import java.time.LocalDateTime;

import org.apache.zookeeper.ZooKeeper;

public class ZkClient{

	public final ZooKeeper zk;
	// public final String name;
	public final String connectString;
	// session timeout in milliseconds
	public final int sessionTimeout ;
	
	public final long sessionId ;
	
	public final String createTime ;

	
	
	public ZkClient(String connectString)throws IOException{
		this(connectString,6000);	
	}

	
	public ZkClient(String connectString,int sessionTimeout)throws IOException{
		// this.zk = zk;
		// this.name=name;
		this.connectString = connectString;
		this.sessionTimeout = sessionTimeout;
		this.zk = new ZooKeeper( connectString, sessionTimeout ,null);
		this.sessionId= zk.getSessionId();
		this.createTime = LocalDateTime.now().toString();
		
	}

}
